




use "${pathdata_robustness}/RobustnessExperiment1.dta", clear
drop if condition_ == "noinfo"

* ### Belief Movement: Main Figure ###	
		
preserve		
		
		
		
	* Step 1: Clone the dataset
gen _clone = 1

* Step 2: Replace the values
* For the cloned dataset
replace effect = bayesian_movement * 100 if _clone == 1
replace effect_recall = bayesian_movement * 100 if _clone == 1
replace treatment = "bayesian_movement_story" if _clone == 1 & inlist(treatment, "n=1_context")
replace treatment = "bayesian_movement_statistic" if _clone == 1 & inlist(treatment, "n>1_nocontext")


duplicates drop


* Step 3: Append the cloned dataset to the original one
append using "${pathdata_robustness}/RobustnessExperiment1.dta", gen(_source)


*keep effect effect_recall bayesian_movement treatment prolific_pid 



	gen temp_group = 0 if inlist(treatment, "n=1_context")
	replace temp_group = 1 if inlist(treatment, "n>1_nocontext")
	replace temp_group = 2 if inlist(treatment, "bayesian_movement_story")
	replace temp_group = 3 if inlist(treatment, "bayesian_movement_statistic")
	keep if story_type=="consistent"
	bysort prolific_pid : drop if _N==1

drop if treatment == "noinfo"

collapse (mean) effect effect_recall (sem) imm_sem = effect del_sem = effect_recall, by(temp_group)	 
	rename imm_sem sem0
	rename del_sem sem1
	rename effect dev0
	rename effect_recall dev1
	reshape long sem dev, i(temp_group) j(delay)
	gen upper=dev+sem
	gen lower=dev-sem

	tw (scatter dev delay if temp_group == 0, connect(l) lcolor(ebblue*1.5) lpattern(dash)  msize(large) ms(d) mcolor(ebblue*1.5)) ///
		(scatter dev delay if temp_group == 1, connect(l) lcolor(red*1.5) lpattern(dash)   msize(large) ms(o) mcolor(red*1.5)) ///
			(scatter dev delay if temp_group == 2, connect(l) lpattern(dash) msize(0.000001) ms(d) lcolor(ebblue*0.5) mcolor(ebblue*0.5)) ///
			(scatter dev delay if temp_group == 3, connect(l) lpattern(dash) msize(0.000001) ms(d) lcolor(red*0.5) mcolor(red*0.5)) ///
		(rcap upper lower delay if temp_group == 0, lw(medthick) lcolor(ebblue*1.5))	///
		(rcap upper lower delay if temp_group == 1, lw(medthick) lcolor(red*1.5)),	///
	ytitle("Mean belief impact {c 177} SEM" "(percentage points)") ///
		xtitle(" ") xsc(r(-0.5 1.5) lcolor(none)) ysc(r(0 20) lcolor(none)) ///
		yline(0, lcolor(gs10) lwidth(thin)) ///
		graphregion(color(white)) title("Belief impact in {it:Immediate} and {it:Delay}",  margin(b=3) color(black)) ///
		ylabel(0 5 10 15 20, tlc(none) angle(0) glcolor(gs15) glwidth(thin)) ///
		legend(order(1 2 3 4) label(1 "Story") label(2 "Statistic") label(3 "Bayesian Benchmark: Story") label(4 "Bayesian Benchmark: Statistic") r(1)) ///
		xlabel(0 "Immediate" 1 "1-day delay") ysize(5) xsize(10)				
	graph export "${pathout_robustness}/figures/figureA1a.pdf", replace
	

restore



* ########## Combined Recall - Main Figure ##########
preserve
	* ### RECALL GRAPH ###
collapse (mean) correct_recall (sem) stderr = correct_recall, by (treatment)
rename correct_recall  dev
gen upper = dev + stderr
gen lower = dev - stderr


egen treatment_num = group(treatment)

tw (scatter dev treatment_num if treatment == "n=1_context", connect(l) mcolor(ebblue*1.5) ms(d)) ///
   (scatter dev treatment_num if treatment =="n>1_nocontext" , connect(l) mcolor(red*1.5) ms(o)) ///
   (rcap upper lower treatment_num if treatment == "n=1_context", lw(medthick) lcolor(ebblue*1.5)) ///
   (rcap upper lower treatment_num if treatment == "n>1_nocontext", lw(medthick) lcolor(red*1.5)) ///
   , ytitle("Mean Rate  {c 177} SEM") ///
   xtitle(" ") xsc(r(0.5 2.5) lcolor(none)) ysc(r(0 1) lcolor(none)) ///
   yline(0, lcolor(gs10) lwidth(thin)) ///
   graphregion(color(white)) title("Correct recall of information treatment and valence", color(black)) ysize(6) xsize(9) ///
   ylabel(0(0.1)1, tlc(none) angle(0) glcolor(gs15) glwidth(thin)) ///
   legend(off) ///
   xlabel(1 "Story" 2 "Statistic", valuelabel)
   
	graph export "${pathout_robustness}/figures/figureA1b.pdf", replace







